//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by 张子国 on 15/11/9.
//  Copyright © 2015年 张子国. All rights reserved.
//

import UIKit

//oc中没有多继承用协议代替

class BaseTableViewController: UITableViewController,VisitorloginViewDelegate {
    
    //用户登录标记
//  var userLogin = false
    var userLogin = UserAccountViewModel().userLogin

    var visitorLoginView : VisitorloginView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : setUpView()
        
        
        
    }
    
    private func setUpView () {
        
        view = VisitorloginView()
        visitorLoginView = VisitorloginView()
        //view = visitorLoginView
        
        //设置代理
        visitorLoginView?.visitorDelegate = self
        
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        
        
    }
    
    //MARK:visitorDelegate 协议方法
    func visitorWillRegister() {
//        print("come on")
    }
    
    func visitorWillLogin() {
//        print("come in")
        
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        
    }
    
}